<?
	require "lib.php";	
	
	if(!boardExists($_GET["bid"])) alertAndBack("존재하지 않는 게시판 입니다!");
	$article = getArticle($_GET["bid"], intval($_POST["id"]));	
		
	$board_info = boardInfo($_GET["bid"]);
	if($article["memberid"] != $_SESSION["loginIdx"] && $_SESSION["loginAdmin"] != "True" && $board_info["writeadmin"] == "1") { alertAndBack("권한이 없습니다!"); exit; }
	if($_POST["title"] && $_POST["content"]) {		
		if(updateArticle($_GET["bid"], addslashes($_POST["title"]), addslashes($_POST["content"]), intval($_POST["id"]))) {
			alertAndMove("글 수정 성공!", "list.php?bid=".$_GET["bid"]);
			exit;
		}
		else { alertAndBack("글 수정 실패"); exit; }
	}
	else { alertAndBack("빈 칸이 있습니다!"); exit; }
?>